<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <form onsubmit="func(event)">
      <label>
        名字：
        <input type="text" />
      </label>
      <input type="submit" value="提交" />
    </form>
  </body>
  <script>
    function func(e) {
      console.log(document.forms);
      e.preventDefault();
    }
  </script>
</html>
